package com.snowRemovingUser.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.snowRemovingUser.domain.SigningCustomer;
import com.snowRemovingUser.service.ISigningCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 气象服务签约客户Controller
 * 
 * @author fz
 * @date 2024-04-24
 */
@RestController
@RequestMapping("/snowRemoving/signingCustomer")
public class SigningCustomerController extends BaseController
{
    @Autowired
    private ISigningCustomerService signingCustomerService;

    /**
     * 查询气象服务签约客户列表
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:signingCustomer:list')")
    @GetMapping("/list")
    public TableDataInfo list(SigningCustomer signingCustomer)
    {
        startPage();
        List<SigningCustomer> list = signingCustomerService.selectSigningCustomerList(signingCustomer);
        return getDataTable(list);
    }

    /**
     * 导出气象服务签约客户列表
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:signingCustomer:export')")
    @Log(title = "气象服务签约客户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SigningCustomer signingCustomer)
    {
        List<SigningCustomer> list = signingCustomerService.selectSigningCustomerList(signingCustomer);
        ExcelUtil<SigningCustomer> util = new ExcelUtil<SigningCustomer>(SigningCustomer.class);
        util.exportExcel(response, list, "气象服务签约客户数据");
    }

    /**
     * 获取气象服务签约客户详细信息
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:signingCustomer:query')")
    @GetMapping(value = "/{signingCustomerId}")
    public AjaxResult getInfo(@PathVariable("signingCustomerId") String signingCustomerId)
    {
        return success(signingCustomerService.selectSigningCustomerBySigningCustomerId(signingCustomerId));
    }

    /**
     * 新增气象服务签约客户
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:signingCustomer:add')")
    @Log(title = "气象服务签约客户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SigningCustomer signingCustomer)
    {
        return toAjax(signingCustomerService.insertSigningCustomer(signingCustomer));
    }

    /**
     * 修改气象服务签约客户
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:signingCustomer:edit')")
    @Log(title = "气象服务签约客户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SigningCustomer signingCustomer)
    {
        return toAjax(signingCustomerService.updateSigningCustomer(signingCustomer));
    }

    /**
     * 删除气象服务签约客户
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:signingCustomer:remove')")
    @Log(title = "气象服务签约客户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{signingCustomerIds}")
    public AjaxResult remove(@PathVariable String[] signingCustomerIds)
    {
        return toAjax(signingCustomerService.deleteSigningCustomerBySigningCustomerIds(signingCustomerIds));
    }
}
